package com.sky;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;

@SpringBootTest
public class test2 {
    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    public void testString(){
        // set get setex setnx
        redisTemplate.opsForValue().set("name1","小明");
        String city = (String) redisTemplate.opsForValue().get("name1");
        System.out.println(city);
        redisTemplate.opsForValue().set("code","1234",3, TimeUnit.MINUTES);
        redisTemplate.opsForValue().setIfAbsent("lock","1");
        redisTemplate.opsForValue().setIfAbsent("lock","2");
    }
}
